import socket

class TCPServerModule:
    def __init__(self,name,port):
        self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.server_socket.bind((name,port))
        self.server_socket.listen(5)

        self.ClientSockets = []
        self.ClientAddresses = []

    def _AcceptCon(self):
        client_socket, address = self.server_socket.accept()
        print address, "Connected"
        self.ClientSockets.append(client_socket)
        self.ClientAddresses.append(address)

    def _SendData(self,data):
        for client in self.ClientSockets:
            client.send(data)

    def _RecvData(self):
        for x,client in enumerate(self.ClientSockets):
            data = client.recv(1024)
            print data

    def Close(self):
        for client in self.ClientSockets:
            client.close()
        self.server_socket.close()

    
    
